var hasOwnProperty = Object.prototype.hasOwnProperty;
var copy = function (data, weakMap) {
    var a = typeof data;
    if ('object' === a && null !== data) {
        var r = weakMap ? weakMap.get(data) : undefined;
        if (undefined !== r)
            return r;
        if (data instanceof Array) {
            r = [];
            weakMap && weakMap.set(data, r);
            for (var o = 0; o < data.length; o++)
                r[o] = copy(data[o], weakMap);
        } else
            for (var s in (r = {}, weakMap && weakMap.set(data, r), data))
                hasOwnProperty.call(data, s) && (r[s] = copy(data[s], weakMap));
        return r;
    }
    if ('symbol' !== a)
        return data;
};
exports.deepCopy = function (data, weakMap) {
    var i = weakMap && 'undefined' != typeof WeakMap ? new WeakMap() : null;
    return copy(data, i);
};
